import { createApp } from 'vue'
import { createPinia } from 'pinia'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
import piniaPersist from 'pinia-plugin-persistedstate'
import ElementPlus from 'element-plus'  //不需要所有图标可以按需引入
import 'element-plus/dist/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue' // 导入所有图标
import App from './App.vue'
import router from './router'
import 'leaflet/dist/leaflet.css'
import { Swiper, SwiperSlide } from 'swiper/vue';
import 'swiper/swiper-bundle.css';
import '@/assets/main.css'
import { useUserStore } from '@/stores/userStore'

const app = createApp(App)
const pinia = createPinia()
pinia.use(piniaPersist)
pinia.use(piniaPluginPersistedstate)

// 注册所有Element Plus图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

app.use(pinia)
app.use(router)
app.use(ElementPlus)
app.mount('#app')

// 👇 初始化用户状态
const userStore = useUserStore()